Telegram Group & Telegram Channel
Python dasturlash maktabi
Testlarni guruhlarga ulashing! 🗓MUNDARIJA: --------------------------- ⭕️ 1-bo'lim “Asosiy tushunchalar” Ⓜ️ Python nima? Ⓜ️ Birinchi dastur Ⓜ️ Oddiy operatsiyalar Ⓜ️ Haqiqiy sonlar Ⓜ️ Matnlar (strings) Ⓜ️ O'zgaruvchilar (Variables) Ⓜ️ Ma'lumotlarni olish…
Ⓜ️ *args va ** kwargs

Funksiya chaqirilganda argumentlar soni teng bo'lmasa TypeError xatoligini qaytaradi.


def func(argument1, argument2, argument3):
print(argument1 * argument2 + argument3)


func(2, 6)

TypeError: func() missing 1 required positional argument: 'argument3'


Funksiyalarda o'zgaruvchan miqdordagi argumentlarni uzatish uchun maxsus belgilardan *, ** foydalaniladi.

*args (kalit-qiymatsiz argumentlar)
**kwargs (kalit-qiymatli argumentlar)

args va kwargs shunchaki argumentlar ro'yxatiga berilgan nom.Bu nomni boshqa istalgan nomga o'zgartirishingiz mumkin.
Masalan: *kalitsiz va **kalitli. Lekin dastur biror jamoa tomonidan yoziladigan bo'lsa yoki dastur kodi sotilishi rejalashtirilgan bo'lsa argumentlar roʻyxatini args va kwargs kabi nomlash maqsadga muvofiqdir.

Argsga misol:

def func(arg1, *arg):
print('Birinchi argument: ' + arg1)
for i in arg:
print('Boshqa argument: ' + i)


func('@pythonuz', '@js_uz', '@phpuz', '@pyqt5')


Birinchi argument: @pythonuz
Boshqa argument: @js_uz
Boshqa argument: @phpuz
Boshqa argument: @pyqt5


Kwargsga misol:


def func(**kwarg):
for x, y in kwarg.items():
print('Kalit: ' + x, ' Qiymat: ' + y)


func(python='django', javascript='react', php='laravel')

Kalit: python Qiymat: django
Kalit: javascript Qiymat: react
Kalit: php Qiymat: laravel

@pythonuz



tg-me.com/pythonuz/540
Create:
Last Update:

Ⓜ️ *args va ** kwargs

Funksiya chaqirilganda argumentlar soni teng bo'lmasa TypeError xatoligini qaytaradi.


def func(argument1, argument2, argument3):
print(argument1 * argument2 + argument3)


func(2, 6)

TypeError: func() missing 1 required positional argument: 'argument3'


Funksiyalarda o'zgaruvchan miqdordagi argumentlarni uzatish uchun maxsus belgilardan *, ** foydalaniladi.

*args (kalit-qiymatsiz argumentlar)
**kwargs (kalit-qiymatli argumentlar)

args va kwargs shunchaki argumentlar ro'yxatiga berilgan nom.Bu nomni boshqa istalgan nomga o'zgartirishingiz mumkin.
Masalan: *kalitsiz va **kalitli. Lekin dastur biror jamoa tomonidan yoziladigan bo'lsa yoki dastur kodi sotilishi rejalashtirilgan bo'lsa argumentlar roʻyxatini args va kwargs kabi nomlash maqsadga muvofiqdir.

Argsga misol:

def func(arg1, *arg):
print('Birinchi argument: ' + arg1)
for i in arg:
print('Boshqa argument: ' + i)


func('@pythonuz', '@js_uz', '@phpuz', '@pyqt5')


Birinchi argument: @pythonuz
Boshqa argument: @js_uz
Boshqa argument: @phpuz
Boshqa argument: @pyqt5


Kwargsga misol:


def func(**kwarg):
for x, y in kwarg.items():
print('Kalit: ' + x, ' Qiymat: ' + y)


func(python='django', javascript='react', php='laravel')

Kalit: python Qiymat: django
Kalit: javascript Qiymat: react
Kalit: php Qiymat: laravel

@pythonuz

BY Python dasturlash maktabi


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/pythonuz/540

View MORE
Open in Telegram


Python dasturlash maktabi Telegram | DID YOU KNOW?

Date: |

The global forecast for the Asian markets is murky following recent volatility, with crude oil prices providing support in what has been an otherwise tough month. The European markets were down and the U.S. bourses were mixed and flat and the Asian markets figure to split the difference.The TSE finished modestly lower on Friday following losses from the financial shares and property stocks.For the day, the index sank 15.09 points or 0.49 percent to finish at 3,061.35 after trading between 3,057.84 and 3,089.78. Volume was 1.39 billion shares worth 1.30 billion Singapore dollars. There were 285 decliners and 184 gainers.

Export WhatsApp stickers to Telegram on iPhone

You can’t. What you can do, though, is use WhatsApp’s and Telegram’s web platforms to transfer stickers. It’s easy, but might take a while.Open WhatsApp in your browser, find a sticker you like in a chat, and right-click on it to save it as an image. The file won’t be a picture, though—it’s a webpage and will have a .webp extension. Don’t be scared, this is the way. Repeat this step to save as many stickers as you want.Then, open Telegram in your browser and go into your Saved messages chat. Just as you’d share a file with a friend, click the Share file button on the bottom left of the chat window (it looks like a dog-eared paper), and select the .webp files you downloaded. Click Open and you’ll see your stickers in your Saved messages chat. This is now your sticker depository. To use them, forward them as you would a message from one chat to the other: by clicking or long-pressing on the sticker, and then choosing Forward.

Python dasturlash maktabi from us


Telegram Python dasturlash maktabi
FROM USA